package org.bt.common.validator.aspect;

import org.bt.common.constant.CommonConstant;
import org.bt.common.validator.size.*;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * Size
 * <p>
 * Created on 2020/1/9
 *
 * @author tongw
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Size.List.class)
@Documented
@Constraint(
        validatedBy = {
                SizeValidatorForCharSequence.class,
                SizeValidatorForCollection.class,
                SizeValidatorForArray.class,
                SizeValidatorForMap.class,
                SizeValidatorForArraysOfBoolean.class,
                SizeValidatorForArraysOfByte.class,
                SizeValidatorForArraysOfChar.class,
                SizeValidatorForArraysOfDouble.class,
                SizeValidatorForArraysOfFloat.class,
                SizeValidatorForArraysOfInt.class,
                SizeValidatorForArraysOfLong.class,
                SizeValidatorForArraysOfShort.class
        }
)
public @interface Size {

    String message() default CommonConstant.Valid.SIZE;

    String name() default "集合条目";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    int min() default 0;

    int max() default 2147483647;

    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface List {
        Size[] value();
    }
}
